export default function (datas) {
    var colorList = ['#f36c6c', '#e6cf4e', '#20d180', '#0093ff'];
    var datas = datas
    let maxArr = (new Array(datas.length)).fill(100);
    return {
        "title": {
            "subtext": "供应商统计信息",
            x: "4%",
            y:'-1%',
            subtextStyle: {
                color: 'black',
                fontSize: '18',
            },
        },
        backgroundColor:'#fff',
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },

        legend: {
            show: false
        },
        grid: {
            height:'calc(100%)',
            left: -10,
            right:'8%',
            top:"10%",
            containLabel:true,
        },
        xAxis: {
            show: false,
            type: 'value'

        },
        yAxis: [{
            type: 'category',
            inverse: true,
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisPointer: {
                label: {
                    show: true,
                    margin: 30
                }
            },
            data: datas.map(item => item.name),
            axisLabel: {
                margin: 100,
                fontSize: 14,
                align: 'left',
                color: '#333',
                rich: {
                    a1: {
                        color: '#fff',
                        backgroundColor: colorList[2],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a2: {
                        color: '#fff',
                        backgroundColor: colorList[2],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a3: {
                        color: '#fff',
                        backgroundColor: colorList[2],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a4: {
                        color: '#fff',
                        backgroundColor: colorList[2],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a5: {
                        color: '#fff',
                        backgroundColor: colorList[0],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a6: {
                        color: '#fff',
                        backgroundColor: colorList[1],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a7: {
                        color: '#fff',
                        backgroundColor: colorList[2],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a8: {
                        color: '#fff',
                        backgroundColor: colorList[3],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a9: {
                        color: '#fff',
                        backgroundColor: colorList[0],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    a10: {
                        color: '#fff',
                        backgroundColor: colorList[1],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    },
                    b: {
                        color: '#fff',
                        backgroundColor: colorList[2],
                        width: 30,
                        height: 30,
                        align: 'center',
                        borderRadius: 2
                    }
                },
                formatter: function(params) {
                    var index = datas.map(item => item.name).indexOf(params);
                    index = index + 1;
                    if (index - 1 < 3) {
                        return [
                            '{a' + index + '|' + index + '}' + '  ' + params
                        ].join('\n')
                    } else {
                        return [
                            '{b|' + index + '}' + '  ' + params
                        ].join('\n')
                    }
                }
            }
        }, {
            type: 'category',
            inverse: true,
            axisTick: 'none',
            axisLine: 'none',
            show: true,
            data: datas.map(item => item.value),
            axisLabel: {
                show:true,
                fontSize: 14,
                color: '#333',
                formatter:'{value}%'
            }
        }],
        series: [{
                z: 2,
                name: '质量',
                type: 'bar',
                barWidth: 20,
                zlevel: 1,
                data: datas.map((item, i) => {
                    var itemStyle = {
                        color: i > 11 ? colorList[3] : colorList[3]
                    }
                    return {
                        value: item.value,
                        itemStyle: itemStyle
                    };
                }),
                label: {
                    show: false,
                    position: 'right',
                    color: '#333333',
                    fontSize: 14,
                    offset: [10, 0]
                }
            },
            {
                name: '对比值',
                type: 'bar',
                barWidth: 20,
                barGap: '-100%',
                itemStyle: {
                    normal: {
                        color: 'rgba(118, 111, 111, 0.55)'
                    }
                },
                data: maxArr,
            }

        ]
    };

}
